package server.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;

public class FileUtil {
    public static void sendData(File file, OutputStream stream) throws IOException {
        if (stream == null)
            return;
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(file);
            byte[] buffer = new byte[2048];
            int len = 0;
            while ((len = fis.read(buffer)) != -1) {
                stream.write(buffer, 0, len);
            }
        } finally {
            if (fis != null)
                fis.close();
        }
    }
}
